package cn.zysheep.feign.clients.callback;

import cn.zysheep.feign.clients.UserClient;
import cn.zysheep.feign.pojo.User;
import org.springframework.stereotype.Component;

/**
 * @version v1.0
 * @Author: lyw
 * @Date: 2021/8/17
 */
/**
 *实现自定义的UserClient接口,在接口实现类中编写熔断降级方法
 *需要注册为ioc容器中的bean
 */
@Component
public class UserClientCallBack implements UserClient {
    /**
     * 降级方法
     * @param id
     * @return
     */
    @Override
    public User queryById(Long id) {
        User user = new User();
        user.setId(-1L);
        user.setUsername("熔断:触发降级方法");
        return user;
    }
}
